﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceab.DTO;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace RBACDuYaJun.Api.Controllers
{
    /// <summary>
    /// 屠宰信息/屠宰企业
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        /// <summary>
        /// 屠宰服务层
        /// </summary>
        private readonly ISlaughterService _slaughterService;
        /// <summary>
        /// 屠宰企业信息服务层
        /// </summary>
        private readonly ISlPriseService _lpriseService;
        public SlaughterController(ISlaughterService slaughterService, ISlPriseService slPriseService)
        {
            _slaughterService = slaughterService;
            _lpriseService = slPriseService;
        }


        /// <summary>
        /// 添加屠宰信息
        /// </summary>
        /// <param name="slaughter"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddSlaughter(Slaughter slaughter)
        {
           return await _slaughterService.AddSlaughter(slaughter);
        }
        /// <summary>
        /// 显示屠宰信息
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Slaughter>> GetSlaughter(string bath)
        {
          return await _slaughterService.GetSlaughter(bath);
        }
        /// <summary>
        /// 反填屠宰信息
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Slaughter>> GetSlaughterBy(string bath)
        {
            return await _slaughterService.GetSlaughterBy(bath);
        }
        /// <summary>
        /// 修改屠宰信息
        /// </summary>
        /// <param name="slaughter"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateSlaughter(Slaughter slaughter)
        {
            return await _slaughterService.UpdateSlaughter(slaughter);
        }
        /// <summary>
        /// 添加屠宰企业信息
        /// </summary>
        /// <param name="enterPrise"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddSSlPrise(SlaughterEnterPrise enterPrise)
        {
           return await _lpriseService.AddSSlPrise(enterPrise);
        }
        /// <summary>
        /// 显示屠宰企业信息
        /// </summary>
        /// <param name="batch"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SlPriseDTO>> GetSlaughterEnterPrises(string batch)
        {
            return await _lpriseService.GetSlaughterEnterPrises(batch);
        }
        /// <summary>
        /// 修改屠宰企业信息
        /// </summary>
        /// <param name="slaughterEnterPrise"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateSlPrise(SlaughterEnterPrise slaughterEnterPrise)
        {
            return await _lpriseService.UpdateSlPrise(slaughterEnterPrise);
        }
    }
}
